
import {ref} from 'vue'

export default function(_userInfo) {


	const show = ref(false);
	const showPopup = () => {
		show.value = true;
	};
	const hidePopup = () => {
		show.value = false;
	};

	let addr_code = ref(_userInfo.value.addr_code?String(_userInfo.value.addr_code[2]):'')

	function confirm(e) {

		let addr = []
		let addr_code = []

		e.selectedOptions.forEach(v => {
			console.log(v)
			addr.push(v.text)
			addr_code.push(v.value)
		})


		_userInfo.value.addr = addr.join('-')
		_userInfo.value.addr_code = addr_code


		
		hidePopup()

	}

	function cancel(e) {
		hidePopup()
	}
	
	return {
		show,
		showPopup,
		hidePopup,
		confirm,
		cancel,
		addr_code
	}

}